<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<html>
<head>
<script type="text/javascript">
jQuery(function(){ 
	var v = "${state}";
	var type = document.getElementById("state");
	for(i = 0;i <= type.options.length; i++){
		if(type.options[i].value == v){
			type.options[i].selected = 'selected';
		}
	}
}); 

function update(playerId, id, state) {
	var params = {
		playerId: playerId,
		id : id,
		state : state
	};
	$.getJSON("updateActivityCalendar.do",params,function(data){
		if(data.msg=="success") {
			location.reload();
		} else {
			alert(data.msg);
		}
	});
	
}
</script>

</head>
<body>
<form class="form-horizontal" action="activityCalendar.do" method="post">
	<div class="control-group">
		<label class="control-label">状态:</label>
		<div class="controls">
		<select name="state" id="state">
			<option value=""></option>
			<option value="0">待审批</option>
			<option value="1">通过</option>
			<option value="-1">不通过</option>
		</select>
		 <button type="submit" class="btn">查询</button>
		</div>
	</div>
</form>
<table class="table table-bordered">
  <caption>活动日历</caption>
  <thead>
    <tr>
      <th>申请时间</th>
      <th>申请人</th>
      <th>活动类型</th>
      <th>活动名称</th>
      <th>活动房间</th>
      <th>活动开始时间</th>
      <th>状态</th>
      <th>操作</th>
    </tr>
  </thead>
  <tbody>
  <c:forEach var="application" items="${list}">
    <tr>
      <td><fmt:formatDate value="${application.applyTime}" pattern="yyyy-MM-dd HH:mm:ss" type="date" /></td>
      <td><tags:user id="${application.playerId}"/></td>
      <td>${application.activityType}</td>
      <td>${application.activityName}</td>
      <td>${application.roomId}</td>
      <td><fmt:formatDate value="${application.activityTime}" pattern="yyyy-MM-dd HH:mm" type="date" /></td>
      <td>
      	<c:if test="${application.state == 0}">待审批</c:if>
      	<c:if test="${application.state == 1}">通过</c:if>
      	<c:if test="${application.state == -1}">不通过</c:if> 
      </td>
      <td>
      	<c:if test="${application.state == 0}"><a href="javascript:void()" onclick="javascript: update('${application.playerId}', '${application.id}', '1')">通过</a> &nbsp;&nbsp;&nbsp;&nbsp; 
      	<a href="javascript:void()" onclick="javascript: update('${application.playerId}', '${application.id}', '-1')">不通过</a></c:if>
      </td>
    </tr>
  </c:forEach>
  </tbody>
</table>
 <tags:page1 page="${page}" pageSize="${pageSize }" total="${total }" url="?state=${state}&page="/>
</body>
</html>